<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox float-e-margins">
				<div class="ibox-content">
					<form class="form-horizontal m-t" id="signupForm">
						<input id="id" name="id" th:value="${works.id}"  type="hidden">
						<div class="form-group">
							<label class="col-sm-2 control-label">流水号：</label>
							<div class="col-sm-4">
								<input id="sn" name="sn" th:value="${works.sn}" class="form-control" type="text">
							</div>

							<label class="col-sm-2 control-label">提交日期：</label>
							<div class="col-sm-4">
								<div class="input-group date" id='date1'>
									<input id="submitDate" name="submitDate" th:value="${works.submitDate}" type="text" class="form-control">
									<span class="input-group-addon">
												<i class="glyphicon glyphicon-calendar"></i>
											</span>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">登记类型：</label>
							<div class="col-sm-4">
								<select id="businessType" name="businessType" class="selectpicker"  style="width:100%;height:34px">
									<option th:selected="(${works.businessType}==0)" value="0">新登记</option>
									<option th:selected="(${works.businessType}==1)" value="1">撤销</option>
									<option th:selected="(${works.businessType}==2)" value="2">转让</option>
									<option th:selected="(${works.businessType}==3)" value="3">变更</option>
									<option th:selected="(${works.businessType}==4)" value="4">查询</option>
									<option th:selected="(${works.businessType}==5)" value="5">补发</option>
									<option th:selected="(${works.businessType}==6)" value="6">撤回</option>
									<option th:selected="(${works.businessType}==7)" value="7">质权登记</option>
									<option th:selected="(${works.businessType}==8)" value="8">注销质权</option>
								</select>
							</div>

							<label class="col-sm-2 control-label">作品类型：</label>
							<div class="col-sm-4">

								<select id="worksType" name="worksType" class="selectpicker"  style="width:100%;height:34px">

									<option th:each="worksType:${worksTypeList}" th:selected="(${works.worksType}==${worksType.id})" th:value="${worksType.id}" th:text="${worksType.name}"></option>
								</select>
							</div>
						</div>
						<div class="form-group">


							<label class="col-sm-2 control-label">著作权人：</label>
							<div class="col-sm-4">
								<input id="copyrightOwner" name="copyrightOwner" th:value="${works.copyrightOwner}" class="form-control" type="text">
							</div>

							<label class="col-sm-2 control-label">作品名称：</label>
							<div class="col-sm-4">
								<input id="worksName" name="worksName" th:value="${works.worksName}" class="form-control" type="text">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">是否系列：</label>
							<div class="col-sm-4">
								<label class="radio-inline"> <input type="radio" th:field="*{works.isSerial}"  name="isSerial" value="1" /> 是</label>
								<label class="radio-inline"> <input type="radio" th:field="*{works.isSerial}"  name="isSerial" value="0" /> 否</label>
							</div>
							<label class="col-sm-2 control-label">工作日：</label>
							<div class="col-sm-4">
								<select id="workingDays" name="workingDays" class="selectpicker"  style="width:100%;height:34px">
									<option th:selected="(${works.workingDays}==0)" value="0" selected>普件</option>
									<option th:selected="(${works.workingDays}==31)" value="31">31工作日</option>
									<option th:selected="(${works.workingDays}==26)" value="26">26-30工作日</option>
									<option th:selected="(${works.workingDays}==21)" value="21">21-25工作日</option>
									<option th:selected="(${works.workingDays}==16)" value="16">16-20工作日</option>
									<option th:selected="(${works.workingDays}==11)" value="11">11-15工作日</option>
									<option th:selected="(${works.workingDays}==6)" value="6">6-10工作日</option>
									<option th:selected="(${works.workingDays}==5)" value="5">5工作日</option>
									<option th:selected="(${works.workingDays}==4)" value="4">4工作日</option>
									<option th:selected="(${works.workingDays}==3)" value="3">3工作日</option>
									<option th:selected="(${works.workingDays}==2)" value="2">2工作日</option>
									<option th:selected="(${works.workingDays}==1)" value="1">1工作日</option>
								</select>
							</div>

						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">代理公司：</label>
							<div class="col-sm-4">
								<select id="agentCompany" name="agentCompany" class="selectpicker"  style="width:100%;height:34px">
									<option th:each="agent:${agentList}"  th:selected="(${works.agentCompany}==${agent.name})" th:value="${agent.name}" th:text="${agent.name}"></option>
								</select>
							</div>
							<label class="col-sm-2 control-label">出证日期：</label>
							<div class="col-sm-4">
								<div class="input-group date" id='date2'>
									<input id="approvalDate" name="approvalDate" th:value="${works.approvalDate}"  type="text" class="form-control">
									<span class="input-group-addon">
												<i class="glyphicon glyphicon-calendar"></i>
											</span>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">官费：</label>
							<div class="col-sm-4">
								<input id="officialFees" name="officialFees" th:value="${works.officialFees}" class="form-control" type="text">
							</div>
							<label class="col-sm-2 control-label">加急费：</label>
							<div class="col-sm-4">
								<input id="urgentFees" name="urgentFees" th:value="${works.urgentFees}" class="form-control" type="text">
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label">业务员：</label>
							<div class="col-sm-4">
								<select id="businessMan" name="businessMan" class="selectpicker"  style="width:100%;height:34px">
									<option value="1" selected>请选择业务员</option>
									<option th:each="user:${userList}" th:selected="(${businessMan.userId}==${user.userId})" th:value="${user.userId}" th:text="${user.name}"></option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">特殊情况备注：</label>
							<div class="col-sm-10">
								<textarea id="comments" style="width:100%;" th:text="${works.comments}"   name="comments" rows="8"></textarea>
							</div>
						</div>
						<!--<div class="form-group">
<label class="col-sm-3 control-label">状态：</label>
<div class="col-sm-8">
</div>
</div>-->
						<div class="form-group">
							<div class="col-sm-8 col-sm-offset-3">
								<input id="status" name="status" value="1" type="hidden">
								<button type="submit" class="btn btn-primary">提交</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/js/appjs/biz/works/edit.js">
</script>
<script>
	$(function () {
		$('#date1').datetimepicker({
			format: 'YYYY-MM-DD',
			locale: moment.locale('zh-cn')
		});
	});
</script>
<script>
	$(function () {
		$('#date2').datetimepicker({
			format: 'YYYY-MM-DD',
			locale: moment.locale('zh-cn')
		});
	});
</script>
<script>
	function supp() {
		document.getElementById("supp1").style.display="";
	}
	function unsupp() {
		document.getElementById("supp1").style.display="none";
	}
	function changePrice(price) {
		document.getElementById("urgentFees").value=price;
	}
	$("#workingDays").on("change",function(){

		workDay = $("option:selected",this).val();//
		switch (workDay) {
			case '31':price=300;break;
			case '26':price=400;break;
			case '21':price=700;break;
			case '16':price=1000;break;
			case '11':price=1500;break;
			case '6':price=2000;break;
			case '5':price=3000;break;
			case '4':price=4000;break;
			case '3':price=5000;break;
			case '2':price=10000;break;
			case '1':price=20000;break;
			default:price=0;

		}
		document.getElementById("urgentFees").value=price;
		weeks=Math.floor(workDay/5);

		days=parseInt(workDay)+weeks*2;
		submitDate =document.getElementById("submitDate").value;//
		let date=new Date(submitDate);
		date.setDate(date.getDate()+days);

		if(date.getDay()==6||date.getDay()==0){
			date.setDate(date.getDate()+2);
		}
		document.getElementById("approvalDate").value=dateFormat("YYYY-mm-dd", date);

	});
	function dateFormat(fmt, date) {
		let ret;
		const opt = {
			"Y+": date.getFullYear().toString(),        // 年
			"m+": (date.getMonth() + 1).toString(),     // 月
			"d+": date.getDate().toString(),            // 日
			"H+": date.getHours().toString(),           // 时
			"M+": date.getMinutes().toString(),         // 分
			"S+": date.getSeconds().toString()          // 秒
			// 有其他格式化字符需求可以继续添加，必须转化成字符串
		};
		for (let k in opt) {
			ret = new RegExp("(" + k + ")").exec(fmt);
			if (ret) {
				fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
			};
		};
		return fmt;
	}
</script>
</body>
</html>
